#include "stdint.h"
#include "menu_fsm.h"
#include "./Flexible_Button/flexible_button.h"
#include "./Flexible_Button/flexbutton_porting.h"
#include "./TLSF/tlsf.h"
#include "./TLSF/tlsf_porting.h"
#include "./lw_queue/lw_queue.h"

/********************静态函数声明********************/
static void button_1_press_handle(flex_button_t *btn);
static void button_2_press_handle(flex_button_t *btn);
static void button_3_press_handle(flex_button_t *btn);

/********************全局函数定义********************/

/*用户按键的事件回调函数*/
void user_btn_callback(void *arg)
{
	flex_button_t *btn = (flex_button_t *)arg;

    switch (btn->id)
    {
        case BUTTON_1:
            button_1_press_handle(btn);					
        break;
		
        case BUTTON_2:
            button_2_press_handle(btn);		
        break;
		
		case BUTTON_3:
            button_3_press_handle(btn);		
        break;				       
    }
}

/********************静态函数定义********************/

static void button_1_press_handle(flex_button_t *btn)
{
	switch(btn->event)
	{
		case FLEX_BTN_PRESS_SHORT_START:
		{				
			param_event_t menu_param_event;
			menu_param_event.event = DOWN_SIG;
			lwq_write(&menu_fsm_que, &menu_param_event); /*将事件送入菜单消息队列*/
			break;	
		}							
	}
}

static void button_2_press_handle(flex_button_t *btn)
{
	switch(btn->event)
	{
		case FLEX_BTN_PRESS_SHORT_START:
		{				
			param_event_t menu_param_event;
			menu_param_event.event = CONFIRM_SIG;
			lwq_write(&menu_fsm_que, &menu_param_event); /*将事件送入菜单消息队列*/
			break;	
		}									
	}
}

static void button_3_press_handle(flex_button_t *btn)
{
	switch(btn->event)
	{
		case FLEX_BTN_PRESS_SHORT_START:
		{				
			param_event_t menu_param_event;
			menu_param_event.event = RETURN_SIG;
			lwq_write(&menu_fsm_que, &menu_param_event); /*将事件送入菜单消息队列*/
			break;	
		}								
	}
}
